let persons = [
    { "username": "xiaoming1", "password": "1111" },
    {"username":"xiaoming2","password":"222"},
    {"username":"xiaoming3","password":"33333"}
]
let ophone = document.querySelector('.tel')
let opass = document.querySelector('.pass')
// 登录点击事件
let btn = document.querySelector('.loginbtn')
btn.addEventListener('click', (e) => { 
   console.log(persons);
    var pval = ophone.value;
    var passval = opass.value;
    // for (let i = 0; i < persons.length; i++) {
    //     if (persons[i].username == pval && persons[i].password == passval) {
    //         alert('登录成功')
    //         return;
    //     } else { 
    //         alert('登录失败')
    //         return;
    //     }
        
    // }
    
    var tag=persons.find((item) => { 
        return item.username == pval && item.password == passval
    })
    if (tag) {
        alert('登录成功')
    } else { 
        alert('登录失败')
    }
    e.preventDefault();
})
